package com.haiya.dip;

/**
 * @author qiaoguoqiang
 */
public class DependencyInversion2 {
    public static void main(String[] args) {
        Person1 person = new Person1();
        person.receive(new EmailReceiver());

        person.receive(new WeixinReceiver());

        person.receive(new SmsReceiver());
    }
}

class Person1 {
    public void receive(IReceiver receiver) {
        System.out.println(receiver.getInfo());
    }
}
interface IReceiver {
    String getInfo();
}

class EmailReceiver implements IReceiver {
    @Override
    public String getInfo() {
        return "电子邮件信息: hello email";
    }
}

class WeixinReceiver implements IReceiver {
    @Override
    public String getInfo() {
        return "微信消息: hello wechat";
    }
}

class SmsReceiver implements IReceiver {
    @Override
    public String getInfo() {
        return "短信消息: hello sms";
    }
}